home *** CD-ROM | disk | FTP | other *** search
/ Aminet 25 / Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso / Aminet / comm / mail / PineAB2YAM.lha / PineAB2YAM.rexx < prev   
Encoding:
OS/2 REXX Batch file  |  1998-04-16  |  2.8 KB  |  130 lines

  1. /************************************************************************
  2.  *                                    *
  3.  * PineAB2YAM.rexx    written April 16, 1998 by Graham Waddell    *
  4.  *                                    *
  5.  * This program creates a YAM .addressbook file out of a Pine ADDRBK.TXT*
  6.  * file. See Limitations for more info.                    *
  7.  *                                    *
  8.  * Limitations (aka To Do): Pine address GROUPS/LISTS, and future    *
  9.  *  revisions will be able to open and edit the existing YAM addressbook*
  10.  *  Also, this can't yet handle long comments (2nd line in addrbk.txt)    *
  11.  *  so a LITTLE manual editing is often required ('till next version)    *
  12.  *                                    *
  13.  *                                    *
  14.  * Revision History:                            *
  15.  * v0.1    16-Apr-1998    First release!                    *
  16.  *                                    *
  17.  ************************************************************************
  18.  *                                    *
  19.  * Usage:                                *
  20.  *                                    *
  21.  * "rx PineAB2YAM.rexx [infile (Pine)] [outfile (YAM)]"            *
  22.  *                                    *
  23.  ************************************************************************/
  24.  
  25. OPTIONS results
  26.  
  27. Version = "$VER: PineAB2YAM.rexx v0.1 (04.16.1998)"
  28.  
  29. ARG InFilename ' ' OutFilename    /* Assign variables from CLI input    */
  30.  
  31. /** Main Control Routine begins here **/
  32.     Call Init_Rtn
  33.     DO While ~EOF('InFile')
  34.         Call Process_Record_Rtn
  35.     END
  36.     Call Termination_Rtn
  37.  
  38. /** End of Main Control Routine **/
  39.  
  40.  
  41. /** Initialization Routine begins here **/
  42. Init_Rtn:
  43.  
  44. IF ~SHOW('L',"rexxsupport.library") THEN DO
  45.     IF ADDLIB('rexxsupport.library',0,-30,0) THEN NOP
  46.     ELSE DO
  47.         SAY "rexxsupport.library not available, exiting"
  48.         EXIT 10
  49.     END
  50. END
  51.  
  52. InLine = ''
  53. Name = ''
  54. ALias = ''
  55. Address = ''
  56. Remark = ''
  57.  
  58. YAMHeader = 'YAB2 - YAM Addressbook V2'
  59. YAMUserStart = '@USER '
  60. YAMUserEnd = '@ENDUSER'
  61.  
  62. IF ( ( InFilename = '') | ( OutFilename = '') ) Then DO
  63.     Say "rx PineAB2YAM.rexx [infile (Pine)] [outfile (YAM)]"
  64.     Exit 15
  65. END    /* IF InFilename = ''...    */
  66.  
  67. IF Exists( InFilename ) Then Do
  68.     Open( 'InFile', InFilename, 'R' )
  69. END
  70. Else DO
  71.     Say "Cannot find File [" || InFilename || "]!!"
  72.     Exit 20
  73. END        /* If Exists( InFilename ) */
  74.  
  75.     Open( 'OutFile', OutFilename, 'W' )
  76.  
  77.     InLine = ReadLn('InFile')
  78.  
  79.     WriteLn( 'OutFile', YAMHeader)
  80.  
  81. Return 0
  82. /** End of Initialization Routine **/
  83.  
  84.  
  85. /** Process Record Routine begins here **/
  86. Process_Record_Rtn:
  87.  
  88.     Call ParseUser
  89.     Call WriteUser
  90.  
  91.     InLine = ReadLn('InFile')
  92.  
  93. Return 0
  94. /** End of Process Record Routine **/
  95.  
  96.  
  97. /** Termination Routine begins here **/
  98. Termination_Rtn:
  99.  
  100.     Close('InFile')
  101.     Close('OutFile')
  102.  
  103.     Exit 0    /* finished cleanly    */
  104.  
  105. Return 0
  106. /** End of Termination Routine **/
  107.  
  108.  
  109. /***    Procedures follow    ***/
  110. ParseUser:
  111.     PARSE VAR InLine Alias '    ' Name '    ' Address '        ' Remark
  112. /*    Say 'Alias: ['||Alias||']  Name: ['||Name||']  Addr: ['||Address||']'*/
  113.  
  114. Return 0
  115.  
  116. WriteUser:
  117.     WriteLn( 'OutFile', YAMUserStart||Alias)
  118.     WriteLn( 'OutFile', Address)
  119.     WriteLn( 'OutFile', Name)
  120.     WriteLn( 'OutFile', Remark)
  121.     WriteLn( 'OutFile', YAMUserEnd)
  122.  
  123.     Alias = ''
  124.     Address = ''
  125.     Name = ''
  126.     Remark = ''
  127.  
  128. Return 0
  129.  
  130.